import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
// import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const columns: VxeGridProps['columns'] = [
  {
    title: '图片类型',
    field: 'type',
    slots: {
      default: ({ row }) => {
        return renderDict(row.type, DictEnum.MEETING_SERIES_IMG_TYPE, true);
      },
    },
    width: 120,
  },
  {
    title: '移动端图片',
    field: 'mobileImgOssId',
    slots: { default: 'mobileImgOssId' },
    width: 180,
  },
  {
    title: 'PC端图片',
    field: 'pcImgOssId',
    slots: { default: 'pcImgOssId' },
    width: 180,
  },
  {
    title: '缩略图',
    field: 'thumbnailOssId',
    slots: { default: 'thumbnailOssId' },
    width: 180,
  },
  {
    title: '跳转链接',
    field: 'jumpUrl',
    width: 260,
    slots: { default: 'jumpUrl' },
    showOverflow: true,
  },
  // {
  //   title: '排序',
  //   field: 'sort',
  //   width: 90,
  // },
  {
    title: '状态',
    field: 'status',
    width: 150,
    slots: { default: 'status' },
  },
  {
    title: '备注',
    field: 'remark',
    visible: false,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: '',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '系列ID',
    fieldName: 'seriesId',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '图片类型',
    fieldName: 'type',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.MEETING_SERIES_IMG_TYPE, true),
    },
    rules: 'selectRequired',
  },
  {
    label: '移动端图片',
    fieldName: 'mobileImgOssId',
    component: 'FileUpload',
    componentProps: {
      accept: '.jpg,.jpeg,.png',
    },
    rules: 'selectRequired',
  },
  {
    label: 'PC端图片',
    fieldName: 'pcImgOssId',
    component: 'FileUpload',
    componentProps: {
      accept: '.jpg,.jpeg,.png',
    },
    rules: 'selectRequired',
  },
  {
    label: '缩略图',
    fieldName: 'thumbnailOssId',
    component: 'FileUpload',
    componentProps: {
      accept: '.jpg,.jpeg,.png',
    },
    dependencies: {
      if: (values) => values?.type === 2, // banner图片类型
      triggerFields: ['type'],
    },
    rules: 'selectRequired',
  },
  {
    label: '跳转链接',
    fieldName: 'jumpUrl',
    component: 'Input',
    dependencies: {
      if: (values) => values?.type === 2, // banner图片类型
      triggerFields: ['type'],
    },
    help: '点击Banner图片时跳转的链接地址',
  },
  // {
  //   component: 'InputNumber',
  //   fieldName: 'sort',
  //   help: '排序, 数字越小越靠前',
  //   label: '显示排序',
  //   defaultValue: 0,
  //   rules: 'required',
  // },
  {
    label: '状态',
    fieldName: 'status',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
      optionType: 'button',
    },
    defaultValue: '0',
    rules: 'selectRequired',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
  },
];
